package com.hdw.auth.service;

import com.hdw.common.vo.PaginationVO;
import com.hdw.auth.api.SysFucaService;
import com.hdw.auth.bean.model.SysFuca;
import com.hdw.auth.mapper.SysFucaMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * sysFuca服务实现类
 * Created by hozeData on 2021/11/21.
 */
@Service
@Transactional
public class SysFucaServiceImpl implements SysFucaService{

    private static final Logger LOGGER = LoggerFactory.getLogger(SysFucaServiceImpl.class);

    @Autowired
    private SysFucaMapper sysFucaMapper;

    @Override
    public int insert(SysFuca sysFuca) {
        return sysFucaMapper.insert(sysFuca);
    }

    @Override
    public int insertSelective(SysFuca sysFuca)  {
        return sysFucaMapper.insertSelective(sysFuca);
    }

    @Override
    public int deleteById(Integer id)  {
        return sysFucaMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int updateByIdSelective(SysFuca sysFuca)  {

        return sysFucaMapper.updateByPrimaryKeySelective(sysFuca);
    }

    @Override
    public int updateById(SysFuca sysFuca)  {
        return sysFucaMapper.updateByPrimaryKey(sysFuca);
    }

    @Override
    public SysFuca getById(Integer id)  {
        return sysFucaMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<SysFuca> findByModel(SysFuca sysFuca)  {
        return sysFucaMapper.findByModel(sysFuca);
    }

    @Override
    public PaginationVO<SysFuca> findPageByModel(SysFuca sysFuca, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum == null? 1 : pageNum, pageSize == null? 10 : pageSize);
        List<SysFuca> quesList = sysFucaMapper.findByModel(sysFuca);
        PageInfo<SysFuca> pageInfo = new PageInfo<>(quesList);
        PaginationVO<SysFuca> paginationVo = new PaginationVO(pageInfo.getTotal(), pageInfo.getList());
        return paginationVo;
    }





}
